package com.jt.tenant.conn;

import com.jt.tenant.app.JTApplication;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

/**
 * Created by DR on 2016/3/2.
 */
@HttpInlet(Conn.INLET_SOFTWARE_UPDATE)
public class GetSoftwareUpdate extends JTAsyGet<GetSoftwareUpdate.Info> {

    public String androidVersion;

    public String token = JTApplication.jtPreferences.readToken();

    public GetSoftwareUpdate(String androidVersion, AsyCallBack asyCallBack) {

        super(asyCallBack);

        this.androidVersion = androidVersion;

    }


    @Override
    protected Info parser(JSONObject object) {

        JSONObject apiTYF = object.optJSONObject("apiTYF");

        JSONObject head = apiTYF.optJSONObject("head");

        Info info = new Info();

        if ((info.code = head.optString("code")).equals("10000")) {

            TOAST = "成功";

            info.msg = head.optString("msg");

            JSONObject jsonObject = apiTYF.optJSONObject("body");

            info.DownloadPath = jsonObject.optString("DownloadPath");

            return info;

        } else {

            TOAST = "失败";

        }

        return info;
    }

    public static class Info {

        public String code,msg;

        public String DownloadPath;
    }
}
